package com.tongqin.distributed;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

/**
 * @author yuantongqin
 * @date 2018/8/8 上午10:13
 */
public class RedisManager {

    private static JedisPool jedisPool;

    static {
        JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
        jedisPoolConfig.setMaxTotal(20);
        jedisPoolConfig.setMaxIdle(10);

        jedisPool = new JedisPool(jedisPoolConfig,"172.16.233.128",6379);

    }
    public static Jedis getJedis() throws Exception {
        if(jedisPool != null){
           return  jedisPool.getResource();
        }
        throw new Exception("jedispool 不能为null");
    }





}
